<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>8.v-bind指令</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style>
        .box {
            width: 500px;
            height: 500px;
        }

        .bg-red {
            background: red;
        }

        .bg-blue {
            background: blue;
        }

        .bg-green {
            background: green;
        }
    
    </style>
</head>
<body>


    <!-- 
        v-bind:class

        用boolean值来觉得当前样式是否生效

     -->

    
    <div id="root">
        <div 
            v-bind:class="[
                'box',
                'aa',
                {
                    'bg-red': num==1,
                    'bg-blue': num==2,
                    'bg-green': num==3
                }
            ]"
            >
        </div>

        <input type="text" v-model="num">
    </div>
        


    <script>
    var vm = new Vue({
        el: "#root",
        data: {
            num: "1"
        }
    })
    
    </script>

</body>
</html>